{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }
        .performance {
            width: 100%;height: 40px;line-height: 40px;padding-left: 10px;border-bottom: #999999 dashed 1px;cursor: pointer;
        }
        .performance_active {
            background: #2db7f5;color: white;border-bottom: #2db7f5 dashed 1px;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
        .shade {
            position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(36, 36, 36, 0.5);display: none;z-index: 10000;
        }
        #processed div {
            padding-left: 2%;
        }
        #processed div:hover {
            background: #cfcfcf;
        }
        #ThreeNavigation div {
            padding-left: 2%;
        }
        #page-footer {
            float: right;height: 40px;padding-top: 5px;text-align: right;padding-right: 2%;
        }
        .regular {
            display: inline-block;vertical-align: top;width: 60px;border-radius: 3px;background: white;border: #cfcfcf solid 1px;height: 30px;line-height: 29px;text-align: center;cursor: pointer;
        }
        .page-list div:hover {
            background: #cfcfcf;color: #0b0b0b;
        }
        .footer-active {
            width: 30px;height: 30px;line-height: 29px;border: #1890ff solid 1px;text-align: center;border-radius: 3px;cursor: pointer;display: inline-block;vertical-align: top;background: #1890ff;color: white;
        }
        .footer {
            width: 30px;height: 30px;line-height: 29px;border: #cfcfcf solid 1px;text-align: center;border-radius: 3px;cursor: pointer;background: white;display: inline-block;vertical-align: top;
        }
        .regular:hover {
            background: #cfcfcf;
        }
        .table_wrap {
            width: 100%;height: 90.5%;overflow: auto;border: #cecece solid 1px;border-left: none;
        }
        .table_wrap table {
            width: 100%;border-collapse: collapse;
            {#table-layout: fixed; #}
        }
        #table td {
            height: 35px;line-height: 35px;border: #cecece solid 1px;font-size: 12px;
        }
        #table thead tr th {
            position: sticky;top: 0;background: #EEEEEE;text-align: center;height: 35px;line-height: 35px;border-right: #cecece solid 1px;border-left: #cecece solid 1px;font-size: 12px;font-weight: normal;
        }
        #table th:last-child,
        #table td:last-child {
            position: sticky;text-align: center;right: 0;width: 100px;background: white;box-shadow: -5px 0 5px #b81900;
        }
        #table tbody tr:nth-child(odd) {
            background: #F7F7F7;
         }
        #table tbody tr:hover {
            background: #EFFBFE;
        }
        #table th:last-child {
            z-index: 3;background: #F4F4F5;
        }
        #table .shadow-right th:last-child::after,
        #table .shadow-right td:last-child::after {
            content: "";position: absolute;top: 0;width: 10px;height: 100%;left: -10px;background: linear-gradient(to left, #cfcfcf, transparent);
        }
        .text-version {
            width: 100%;text-align: center;padding-left: 3px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
        }

        .top_class {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;vertical-align: top;cursor: pointer;
        }
        .top_class_active {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;vertical-align: top;cursor: pointer;color: #2db7f5;border-bottom: #2db7f5 solid 1px;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div style="width: 15%;height: 95%;margin-top: 1.25%;display: inline-block;vertical-align: top;background: white;border: #cfcfcf solid 1px;margin-left: 1%;">
        <div onclick="choose_performance_type(this, 1)" class="performance" {% if OverdueFlag %}style="color: red;"{% endif %}>
            超期流程
        </div>
        <div onclick="choose_performance_type(this, 2)" class="performance performance_active" {% if deadline_flag %}style="color: red;"{% endif %}>
            限期流程
        </div>
        <div onclick="choose_performance_type(this, 3)" class="performance" {% if my_launch_flag %}style="color: red;"{% endif %}>
            我发起的
        </div>
        <div onclick="choose_performance_type(this, 4)" class="performance" {% if overdue_process_flag %}style="color: red;"{% endif %}>
            超期通知
        </div>
    </div>

    <div style="width: 82%;height: 95%;margin-top: 1.25%;display: inline-block;vertical-align: top;background: white;border: #cfcfcf solid 1px;margin-left: 0.5%;">
        <div style="width: 100%;height: 100%;" id="performance_allocation">
            <div style="width: 100%;height: 40px;padding-left: 10px;padding-right: 10px;">
                <div style="height: 40px;float: right;padding-right: 1%;width: 60%;text-align: right;">
                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #cfcfcf;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;已处理</p>
                    </div>

                    <div style="width: 150px;line-height: 40px;height: 40px;display: inline-block;vertical-align: top;">
                        <p style="width: 70px;height: 25px;background: #0b0b0b;margin-top: 7.5px;display: inline-block;vertical-align: top;border-radius: 2px;"></p><p style="display: inline-block;vertical-align: top;">&nbsp;未处理</p>
                    </div>
                </div>
            </div>
            <div class="table_wrap">
                <table id="table" style="width: 100%;{% if not DailyList|length %}height: 100%;{% endif %}">
                    <thead>
                        <tr id="thead-title" style="width: 100%;">
                            <th style="width: 50px;background: #EEEEEE;border-left: none;">序号</th>
                            <th style="width: 150px;">工作来源</th>
                            <th style="width: 300px;">责任科室</th>
                            <th style="width: 100px;">负责人</th>
                            <th style="width: 200px;">开始时间</th>
                            <th style="width: 200px;">结束时间</th>
                            <th style="width: 100px;background: #EEEEEE;border-right: none;">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% if DailyList|length %}
                            {% for datum in DailyList %}
                                <tr style="width: 100%;{% if datum.appove == "false" %}color: #cfcfcf;{% else %}color: #0b0b0b;{% endif %}">
                                    <td title="{{ datum.Serial }}" style="border-left: none;"><div class="text-version">{{ datum.Serial }}</div></td>
                                    <td title="{{ datum.title }}"><div class="text-version">{{ datum.title }}</div></td>
                                    <td title="{{ datum.company }}"><div class="text-version">{{ datum.company }}</div></td>
                                    <td title="{{ datum.responsible_person }}"><div class="text-version">{{ datum.responsible_person }}</div></td>
                                    <td title="{{ datum.start_time }}"><div class="text-version">{{ datum.start_time }}</div></td>
                                    <td title="{{ datum.end_time }}"><div class="text-version">{{ datum.end_time }}</div></td>
                                    <td style="border-right: none;"><div class="text-version" style="cursor: pointer;" onclick="views_detail('{{ datum.id }}', '{{ datum.deadline }}', '{{ datum.flow_id }}', '{{ datum.state }}', '{{ datum.appove }}')">查看</div></td>
                                </tr>
                            {% endfor %}
                        {% else %}
                            <tr style="width: 100%;height: 100%;">
                                <td colspan="9" style="width: 100%;height: 100%;text-align: center;line-height: 100%;border: none;">
                                    暂无数据
                                </td>
                            </tr>
                        {% endif %}
                    </tbody>
                </table>
            </div>

            <div style="width: 100%;height: 40px;background: #EEEEEE;border: #cfcfcf solid 1px;border-top: none;border-left: none;">
                <div style="float: left;height: 40px;padding-top: 5px;width: 40%;">
                    <div style="display: inline-block;vertical-align: top;height: 30px;line-height: 30px;padding-left: 3%;font-size: 12px;">
                        此页显示 {{ views_range_start }}-{{ views_range_end }} 条 &nbsp;&nbsp;&nbsp;共 {{ totals }} 条
                    </div>
                </div>
                <div id="page-footer">
                    <div style="display: inline-block;vertical-align: top;text-align: right;">
                        {% if pages > 1 %}
                            <div class="regular" onclick="change_page_size(1)">首页</div>
                            <div class="regular" onclick="change_page_size({{ pages }} - 1)">上一页</div>
                        {% else %}
                            <div class="regular" style="cursor: no-drop;">首页</div>
                            <div class="regular" style="cursor: no-drop;">上一页</div>
                        {% endif %}
                    </div>

                    <div class="page-list" style="display: inline-block;vertical-align: top;">
                        {% for page in page_list %}
                            {% if pages == page %}
                                <div onclick="change_page_size({{ page }})" class="footer-active">{{ page }}</div>
                            {% else %}
                                <div onclick="change_page_size({{ page }})" class="footer">{{ page }}</div>
                            {% endif %}
                        {% endfor %}
                    </div>

                    <div style="display: inline-block;vertical-align: top;text-align: right;">
                        {% if page_all_number > pages %}
                            <div class="regular" onclick="change_page_size({{ pages }} + 1)">下一页</div>
                            <div class="regular" onclick="change_page_size({{ page_all_number }})">尾页</div>
                        {% else %}
                            <div class="regular" style="cursor: no-drop;">下一页</div>
                            <div class="regular" style="cursor: no-drop;">尾页</div>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="job_detail" class="shade">
        <div id="job_models" style="width: 100%;height: 100%;position: absolute;">
            <div id="this_div" style="width: 800px;background: white;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="job_models_title" style="width: 100%;height: 40px;background: white;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #cfcfcf solid 1px;">
                    <div style="width: 80%;height: 40px;display: inline-block;vertical-align: top;">
                        <div id="top_detail" class="top_class top_class_active" onclick="change_top('1')">详情</div>
                        <div id="top_flow" class="top_class" onclick="change_top('2')">流程图</div>
                    </div>
                    <span onclick="close_job_detail()" style="float: right;line-height: 40px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                </div>

                <div id="flow_detail" style="width: 100%;border-bottom: #cfcfcf solid 1px;padding-bottom: 20px;padding-left: 3%;margin: 0;max-height: 700px;overflow: auto;">
                    <div id="my_planned" style="width: 100%;height: 35px;text-align: center;margin-top: 5px;">
                        <button style="width: 100px;border-radius: 3px;height: 25px;margin-top: 5px;border: #2db7f5 solid 1px;background: #2db7f5;color: white;font-size: 12px;display: none;" id="planned_speed">进度反馈</button>
                    </div>
                    <table style="width: 94%;">
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">工作来源</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="title_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">责任科室</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="company_detail"></td>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">责任人</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="responsible_person_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">开始时间</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="start_time_detail"></td>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">结束时间</td>
                            <td style="width: 40%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="end_time_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">工作描述</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="job_description_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">完成要求</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="complete_requirements_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 35px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">备注</td>
                            <td colspan="3" style="width: 90%;height: 35px;border: #DFDFDF solid 1px;padding-left: 3px;" id="note_detail"></td>
                        </tr>
                        <tr>
                            <td style="width: 10%;height: 70px;border: #DFDFDF solid 1px;background: #F5F5F5;padding-left: 3px;color: #999999;text-align: center;">附件</td>
                            <td colspan="3" style="width: 90%;height: 70px;border: #DFDFDF solid 1px;padding-left: 3px;" id="file_detail">
                            </td>
                        </tr>

                        <tr>
                            <td colspan="4" style="width: 100%;height: 50px;border: none;"></td>
                        </tr>
                        <tr>
                            <td colspan="4" style="width: 100%;height: 40px;line-height: 40px;text-align: center;"><h3>工作进展</h3></td>
                        </tr>
                    </table>
                    <table id="detail_body" style="width: 94%;">

                    </table>
                </div>

                <div id="flow_chart_detail" style="width: 100%;padding-bottom: 20px;padding-left: 3%;margin: 0;min-height: 600px;max-height: 700px;overflow: auto;display: none;align-items: center;flex-direction: column;">

                </div>
            </div>
        </div>
    </div>

    <div id="job_schedule" class="shade" style="z-index: 10111;">
        <div id="schedule_models" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 400px;background: white;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="schedule_models_title" style="width: 100%;height: 40px;background: white;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;text-align: center;line-height: 40px;">
                    <span style="font-size: 18px;">进度反馈</span>
                    <span onclick="close_schedule()" style="float: right;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                </div>

                <div style="width: 100%;border-bottom: #cfcfcf solid 1px;padding-bottom: 20px;margin: 0;padding-right: 2%;padding-left: 2%;">
                    <p><span style="color: red;">*</span> 工作进度：</p>
                    <textarea name="" id="opinion_detail" style="width: 96%;height: 100px;border: #CCCCCC solid 1px;outline: none;"></textarea>

                    <div>
                        <p>上传附件：</p>
                        <div style="width: 100%;height: 40px;display: inline-block;">
                            <div style="width: 40px;height: 40px;display: inline-block;vertical-align: top;">
                                <a href="javascript:;" class="file">
                                    <img src="../../static/personal_center/img/加号_o.png" alt="" onclick="onclick_upload_file()" style="width: 30px;height: 40px;vertical-align: baseline;">
                                    <input type="file" name="regular_main_body" id="regular_main_body" onchange="upload_accessory(this.name)">
                                </a>
                            </div>

                            <div id="upload_file_list" style="width: 80%;height: 100%;display: inline-block;vertical-align: top;margin-left: 19px;">

                            </div>
                        </div>
                    </div>
                </div>

                <div style="width: 100%;height: 38px;text-align: center;">
                    <button id="confirm" style="width: 100px;height: 28px;margin-top: 5px;border: #2db7f5 solid 1px;background: #2db7f5;color: white;letter-spacing: 5px;border-radius: 3px;">确认</button>
                    <button onclick="close_schedule()" style="width: 100px;height: 28px;margin-top: 5px;border: #CCCCCC solid 1px;background: #CCCCCC;letter-spacing: 5px;margin-left: 15px;border-radius: 3px;">取消</button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script src="../../static/system_setup/creat_from/js/jquery-1.10.2.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script>
    <script>
        var all_file_list = [];

        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("personage").className = "add_class";
            document.getElementById("supervision_inspection_management").className = "add-nav-active";
        };

        laydate.render({
            elem: '#start_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        laydate.render({
            elem: '#end_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        function choose_performance_type(ele, type_number) {
            var performance_obj = document.getElementsByClassName("performance");
            for (var i=0; i<performance_obj.length; i++) {
                performance_obj[i].className = "performance";
            }
            ele.className = "performance performance_active";

            if (type_number === 1) {
                window.location.href = "overdue_notice.html";
            }else if (type_number === 2) {
                window.location.href = "deadline_process.html";
            }else if (type_number === 3) {
                window.location.href = "my_instigation.html";
            }else {
                window.location.href = "overdue_process.html";
            }
        }

        let job_models_title = document.querySelector("#job_models_title");
        let job_models = document.querySelector("#job_models");

        job_models_title.addEventListener("mousedown", function (e) {
            let x = e.pageX - job_models.offsetLeft;
            let y = e.pageY - job_models.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                job_models.style.left = e.pageX - x + 'px';
                job_models.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function onclick_upload_file() {
            document.getElementById("regular_main_body").click();
        }

        function upload_accessory(tag_name) {
            var form = new FormData();
            document.getElementById("loading").style.display = "inline-block";
            var files = document.getElementById("regular_main_body").files[0];
            form.append("file", files);
            form.append("fj_number", tag_name)
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/upload_file", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        all_file_list.push(files.name);
                    }
                }
            }
            creat_table(files.name);
        }

        function creat_table(file_name) {
            var html_str = `
                <div style="width: 100%;height: 40px;line-height: 40px;">
                    <div style="width: 79%;height: 100%;display: inline-block;vertical-align: top;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
                        <a target='_blank' href="javascript:;">`+file_name+`</a>
                    </div>
                    <div onclick="RemoveTr(this, '`+file_name+`')" style="width: 18%;height: 100%;display: inline-block;vertical-align: top;text-align: center;font-size: 12px;cursor: pointer;color: red;">
                        删除
                    </div>
                </div>
            `
            $("#upload_file_list").append(html_str)
        }

        function RemoveTr(_this, file_name) {
            var parentNode = _this.parentNode;
            parentNode.remove();
            all_file_list.splice(file_name, 1)
        }


        function views_detail(flow_id, deadline, current_id, flow_state, appove) {
            var form = new FormData();
            form.append("id", flow_id)
            document.getElementById("loading").style.display = "inline-block";
            document.getElementById("job_detail").style.display="table-row";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/work_supervision_detail", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        document.getElementById("title_detail").innerText = JsonDate["obj_detail"]["title"];
                        document.getElementById("company_detail").innerText = JsonDate["obj_detail"]["company"];
                        document.getElementById("responsible_person_detail").innerText = JsonDate["obj_detail"]["responsible_person"];
                        document.getElementById("start_time_detail").innerText = JsonDate["obj_detail"]["start_time"];
                        document.getElementById("end_time_detail").innerText = JsonDate["obj_detail"]["end_time"];
                        document.getElementById("job_description_detail").innerText = JsonDate["obj_detail"]["job_description"];
                        document.getElementById("complete_requirements_detail").innerText = JsonDate["obj_detail"]["complete_requirements"];
                        document.getElementById("note_detail").innerText = JsonDate["obj_detail"]["note"];

                        document.getElementById("regular_main_body").setAttribute("name", JsonDate["fj_number"]);

                        var file_tubiao = ""
                        if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "doc" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "docx"){
                            file_tubiao='<img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;">';
                        }else if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "pdf" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "PDF"){
                            file_tubiao='<img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;">';
                        }else if (JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "xls" || JsonDate["files"]["file_name"].split(".").slice(-1)[0] === "xlsx"){
                            file_tubiao='<img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;">'
                        }else {
                            file_tubiao='<img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;">'
                        }

                        document.getElementById("file_detail").innerHTML = "<a target='_blank' href='" + JsonDate["files"]["file_path"] + "'>" + file_tubiao + "<span>" + JsonDate["files"]["file_name"] + "</span></a>"

                        document.getElementById("planned_speed").setAttribute("onclick", "end_job('" + JsonDate["flow_id"] + "', '" + current_id + "', '" + flow_state + "')")

                        if (flow_state === "one" && appove === "true") {
                            document.getElementById("planned_speed").style.display = "inline-block";
                        }
                        document.getElementById("detail_body").innerHTML = "";
                        for (var i=0; i<JsonDate["FeedbackList"].length; i++) {
                            var ReceiptFile = "";
                            if (JsonDate["FeedbackList"][i]["file_path"].split(",").length > 1) {
                                var file_list = JsonDate["FeedbackList"][i]["file_path"].split(",");
                                for (var tt=0; tt<file_list.length; tt++) {
                                    if (file_list[tt].split(".").slice(-1)[0] === "doc" || file_list[tt].split(".").slice(-1)[0] === "docx"){
                                        var aaaaaaa=`<a href="`+file_list[tt]+`"><img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;"></a>`;
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "pdf" || file_list[tt].split(".").slice(-1)[0] === "PDF"){
                                        aaaaaaa=`<a target="_blank" href="`+file_list[tt]+`"><img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;"></a>`;
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "xls" || file_list[tt].split(".").slice(-1)[0] === "xlsx"){
                                        aaaaaaa=`<a href="`+file_list[tt]+`"><img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;"></a>`
                                    }else if (file_list[tt].split(".").slice(-1)[0] === "PNG" || file_list[tt].split(".").slice(-1)[0] === "png") {
                                        aaaaaaa = `<a href="` + file_list[tt] + `"><img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;"></a>`
                                    }else {
                                        aaaaaaa = "";
                                    }
                                    ReceiptFile = ReceiptFile + aaaaaaa;
                                }

                            }else {
                                if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "doc" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "docx"){
                                    ReceiptFile=`<a href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/word%20(3).png" alt="" style="width: 50px;height: 50px;"></a>`;
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "pdf" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "PDF"){
                                    ReceiptFile=`<a target="_blank" href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/pdf.png" alt="" style="width: 50px;height: 50px;"></a>`;
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "xls" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "xlsx"){
                                    ReceiptFile=`<a href="`+JsonDate["FeedbackList"][i]["file_path"]+`"><img src="../../static/correspondence/img/Excel写入-选中.png" alt="" style="width: 50px;height: 50px;"></a>`
                                }else if (JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "PNG" || JsonDate["FeedbackList"][i]["file_path"].split(".").slice(-1)[0] === "png") {
                                    ReceiptFile = `<a href="` + JsonDate["FeedbackList"][i]["file_path"] + `"><img src="../../static/correspondence/img/PNG%20(1).png" alt="" style="width: 50px;height: 50px;"></a>`
                                }else {
                                    ReceiptFile = "";
                                }
                            }
                            var html_str = `
                                <tr style="width: 100%;">
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;text-align: center;">`+JsonDate["FeedbackList"][i]["time"]+`</td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;text-align: center;font-size: 18px;"><strong>`+JsonDate["FeedbackList"][i]["name"]+`(`+JsonDate["FeedbackList"][i]["state"]+`)`+`</strong></td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;padding-left: 1%;">`+JsonDate["FeedbackList"][i]["audit_note"]+`</td>
                                    <td style="width: 25%;height: 50px;border: #DFDFDF solid 1px;padding-left: 1%;">`+ReceiptFile+`</td>
                                </tr>
                            `
                            $("#detail_body").append(html_str);
                        }

                        var FlowChartDetail = document.getElementById('flow_chart_detail');
                        FlowChartDetail.innerHTML = "";

                        var start_flow = `
                            <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;line-height: 40px;color: white;margin-top: 15px;text-align: center;display: block">开&nbsp;&nbsp;&nbsp;始</div>
                        `
                        $("#flow_chart_detail").append(start_flow)
                        if (JsonDate["flow_dict"]['one']['status'] === 'unaudit') {
                            var one_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">责任人<br>(`+JsonDate["flow_dict"]['one']['name']+`)</div>
                            `
                        }else {
                            one_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">责任人<br>(`+JsonDate["flow_dict"]['one']['name']+`)</div>
                            `
                        }
                        $("#flow_chart_detail").append(one_flow)
                        if (JsonDate["flow_dict"].hasOwnProperty("two")) {
                            if (JsonDate["flow_dict"]['two']['status'] === 'unaudit') {
                                var two_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">分管院长<br>(`+JsonDate["flow_dict"]['two']['name']+`)</div>
                                `
                            }else {
                                two_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">分管院长<br>(`+JsonDate["flow_dict"]['two']['name']+`)</div>
                                `
                            }
                            $("#flow_chart_detail").append(two_flow)
                        }
                        if (JsonDate["flow_dict"]['three']['status'] === 'unaudit') {
                            var three_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">医院质量管理办公室<br>(`+JsonDate["flow_dict"]['three']['name']+`)</div>
                            `
                        }else {
                            three_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">医院质量管理办公室<br>(`+JsonDate["flow_dict"]['three']['name']+`)</div>
                            `
                        }
                        $("#flow_chart_detail").append(three_flow)
                        if (JsonDate["flow_dict"].hasOwnProperty("four")) {
                            if (JsonDate["flow_dict"]['four']['status'] === 'unaudit') {
                                var four_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">院领导<br>(`+JsonDate["flow_dict"]['four']['name']+`)</div>
                                `
                            }else {
                                four_flow = `
                                    <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                    <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">院领导<br>(`+JsonDate["flow_dict"]['four']['name']+`)</div>
                                `
                            }
                            $("#flow_chart_detail").append(four_flow)
                        }
                        if (JsonDate["flow_dict"]['five']['status'] === 'unaudit') {
                            var five_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;text-align: center;font-size: 10px;">发起科室归档<br>(`+JsonDate["flow_dict"]['five']['name']+`)</div>
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #838B8B;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #838B8B;border: #838B8B solid 1px;height: 40px;line-height: 40px;text-align: center;">结&nbsp;&nbsp;&nbsp;束</div>
                            `
                        }else {
                            five_flow = `
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;text-align: center;font-size: 10px;color:white;">发起科室归档<br>(`+JsonDate["flow_dict"]['five']['name']+`)</div>
                                <div><i class="iconfont icon-xia--jiantou" style="font-size: 30px;color: #2db7f5;"></i></div>
                                <div style="min-width: 100px;border-radius: 10px;background: #2db7f5;border: #2db7f5 solid 1px;height: 40px;line-height: 40px;color: white;text-align: center;">结&nbsp;&nbsp;&nbsp;束</div>
                            `
                        }
                        $("#flow_chart_detail").append(five_flow)
                    }
                }
            };
        }

        function close_job_detail() {
            document.getElementById("job_detail").style.display = "none";
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }

        function end_job(flow_id, current_id, flow_state) {
            document.getElementById("job_schedule").style.display = "table-row";
            document.getElementById("confirm").setAttribute("onclick", "schedule_confirm('"+flow_id+"', '" + current_id + "', '" + flow_state + "')")
        }

        function close_schedule() {
            document.getElementById("job_schedule").style.display = "none";
        }

        function schedule_confirm(flow_id, current_id, flow_state) {
            var form = new FormData();
            var audit_note = document.getElementById("opinion_detail").value;
            if (flow_state === "one") {
                if (!audit_note) {
                    alert("请填写工作反馈！");
                    return false
                }
            }
            console.log(all_file_list)
            form.append("file", JSON.stringify(all_file_list));
            form.append("work_id", flow_id)
            form.append("deadline_id", current_id)
            form.append("audit_note", audit_note)
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/deadline_feedback", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("操作成功");
                            window.location.reload();
                        } else {
                            alert(JsonDate["message"]);
                        }
                    }
                }
            };
        }

        // 启动问责
        function InitiateAccountability() {

        }

        function finish_up_job(flow_id, current_id) {
            var form = new FormData();
            form.append("flow_id", flow_id)
            form.append("current_id", current_id)
            document.getElementById("loading").style.display = "inline-block";
            document.getElementById("job_detail").style.display="table-row";
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/supervision-inspection/finish_job", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("操作成功！")
                            window.location.reload()
                        }
                    }
                }
            };
        }

        function change_top(top_type) {
            if (top_type === '1') {
                document.getElementById('top_detail').className = 'top_class top_class_active';
                document.getElementById('top_flow').className = 'top_class';
                document.getElementById('flow_detail').style.display = 'block';
                document.getElementById('flow_chart_detail').style.display = 'none';
            }else {
                var this_div_obj = document.getElementById('this_div');
                document.getElementById('this_div').style.height = this_div_obj.offsetHeight+"px";
                document.getElementById('top_detail').className = 'top_class';
                document.getElementById('top_flow').className = 'top_class top_class_active';
                document.getElementById('flow_detail').style.display = 'none';
                document.getElementById('flow_chart_detail').style.display = 'flex';
            }
        }

        function change_page_size(page_number=1) {
            {#var page_size = document.getElementById('page-size').value;#}
            const url = new URL(window.location.href);
            // 创建URLSearchParams对象
            const params = new URLSearchParams(url.search);
            // 设置某个参数的值
            params.set('page', page_number);
            {#params.set('page_size', page_size);#}
            url.search = params.toString();
            window.location.href = url.href;
        }
    </script>
{% endblock %}
